package nailRepo

import (
	"context"
	"gorm.io/gorm"
	"sync"
)

var lock = &sync.Mutex{} //互斥锁

var singleInstance *NailRepo

type NailRepo *queryCtx

func NewNailRepo(db *gorm.DB) NailRepo {
	if singleInstance == nil {
		lock.Lock()
		defer lock.Unlock()
		if singleInstance == nil {
			SetDefault(db)
			return Q.WithContext(context.Background())
		}
	}
	return *singleInstance
}
